﻿<%@ Page Title="" Language="C#" ClientIDMode=Static MasterPageFile="~/User/User.Master" AutoEventWireup="true" CodeBehind="KC_BZX_Edit.aspx.cs" Inherits="CoolERP_Web.User.KC_BZX_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="../Scripts/lhgdialog/lhgcore.min.js" type="text/javascript"></script>
<script src="../Scripts/lhgdialog/lhgdialog.js" type="text/javascript"></script>
<script type="text/javascript">
    var dg;
    function showSelect() {
        dg = new J.dialog({ id: 'select', title: '选择包装箱', page: 'SelectBZX.aspx', iconTitle: false, cover: true, btnBar: false, rang: true, autoSize: true, width: 1000, height: 700 });
        dg.ShowDialog();
    }
    function addCW() {
        var tr = $("#tbCW tr:first").clone();
        $(tr).find("select").val("");
        $(tr).find("input[type=text]").each(function () { $(this).val(""); });
        $(tr).appendTo("#tbCW");
    }
    function delCW(obj) {
        if ($("#tbCW tr").length > 1)
            $(obj).closest("tr").remove();
        else
            alert("不能删除！至少必须填写一个仓位");
    }
    function checkSubmit() {
        if (isEmpty($("#hidID").val())) {
            alert("请选择包装箱");
            return false;
        }
        var isOk = true;
        var cwList = new Array();
        $("#tbCW tr").each(function (i, item) {
            if (i > 0) {
                var cw = {
                    ckid: $(this).find("select").val(),
                    qu: $(this).find("input[type=text]").eq(0).val(),
                    hang: $(this).find("input[type=text]").eq(1).val(),
                    lie: $(this).find("input[type=text]").eq(2).val(),
                    ceng: $(this).find("input[type=text]").eq(3).val(),
                    ge: $(this).find("input[type=text]").eq(4).val()
                };
                if (isEmpty(cw.ckid) || isEmpty(cw.qu) || isEmpty(cw.hang) || isEmpty(cw.lie) || isEmpty(cw.ceng) || isEmpty(cw.ge)) {
                    alert("请完整填写第" + i + "个仓位信息");
                    isOk = false;
                    return isOk;
                }
                if (cwList.contains(cw)) {
                    alert("有两个相同的仓位信息");
                    isOk = false;
                    return isOk;
                }
                cwList[cwList.length] = cw;
            }
        });
        if (!isOk)
            return false;
        return true;
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td class=tbHead_L></td>
        <td class=tbHead_M><div><b>包装箱建仓</b></div></td>
        <td class=tbHead_R></td>
    </tr>
    <tr>
        <td class=tbBody_L></td>
        <td class=tbBody_M>        
            <table border="0" align=left width=100%>
                <tr>
                    <td style="text-align:right">包装箱：</td>
                    <td><asp:TextBox ID="txtMC" runat="server" CssClass="textbox" ReadOnly=true/>
                        <input type=button value="选择" class=btn_s onclick="showSelect()" />
                        <font color=red>*</font><input type=hidden runat=server id="hidID" /></td>
                </tr>
                <tr><td style="text-align:right; width:150px" valign=top>仓位信息：<br /><input type=button value="添加仓位" onclick="addCW()" class=btn_s/></td>
                    <td valign=top>
                        <table cellpadding=5 cellspacing=0 id="tbCW">
                            <tr>
                                <td>仓库：<asp:DropDownList ID="ddlCKID" runat="server" CssClass="dropdown"/></td>
                                <td>区：<asp:TextBox ID="txtQU" runat="server" CssClass="textbox" MaxLength="2" Width=30px /></td>
                                <td>行：<asp:TextBox ID="txtHANG" runat="server" CssClass="textbox" MaxLength="3" Width=30px onkeyup="txtLimit(this,0)" /></td>
                                <td>列：<asp:TextBox ID="txtLIE" runat="server" CssClass="textbox" MaxLength="3" Width=30px onkeyup="txtLimit(this,0)" /></td>
                                <td>层：<asp:TextBox ID="txtCENG" runat="server" CssClass="textbox" MaxLength="3" Width=30px onkeyup="txtLimit(this,0)" /></td>
                                <td>格：<asp:TextBox ID="txtGE" runat="server" CssClass="textbox" MaxLength="3" Width=30px onkeyup="txtLimit(this,0)" /></td>
                                <td>期初数量：<asp:TextBox ID="txtSL" runat="server" CssClass="textbox" MaxLength="16" Width=50px onchange="txtLimit(this,1)"/></td>
                                <td><input type=button value="删除" onclick="delCW(this)" class=btn_s /></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                    <asp:ImageButton ID="btnSave" runat="server" ImageUrl="~/Images/Common/btn_save0.png" onclick="btnSave_Click" OnClientClick="return checkSubmit();" />&nbsp;&nbsp;
                        <a href="KC_BZX_Query.aspx"><img src="../Images/Common/btn_back0.png" border=0 /></a>&nbsp;&nbsp;
                        <asp:Label ID="lbResult" runat="server" ForeColor="Red"></asp:Label>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
                    </Triggers>
                    </asp:UpdatePanel></td>
                </tr>
            </table>
        </td>
        <td class=tbBody_R></td>
    </tr>
    <tr>
        <td class=tbFoot_L></td>
        <td class=tbFoot_M></td>
        <td class=tbFoot_R></td>
    </tr>
</table>
<asp:HiddenField ID="hdId" runat="server" />
</asp:Content>
